<?php
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
cfc('core')->checklogin();
if($_RQ['op']=='main'){
	$type=intval($_RQ['type']);
	$daytime = mktime(0,0,0,date('m'),date('d'),date('Y'));
	$lastdaytime = $daytime-24*3600;
	$data['credit1inall']=pdo_getsum('core_credit_log',array('type'=>1,'is_add'=>1,'mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']),'fee');
	$data['credit1inallday']=pdo_getsum('core_credit_log',array('type'=>1,'is_add'=>1,'mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid'],'createtime >'=>$daytime),'fee');
	$data['credit1inlastday']=pdo_getsum('core_credit_log',array('type'=>1,'is_add'=>1,'mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid'],'createtime between'=>array($lastdaytime,$daytime)),'fee');
	$data['credit1outall']=pdo_getsum('core_credit_log',array('type'=>1,'is_add'=>0,'mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']),'fee');
	$data['credit2inall']=pdo_getsum('core_credit_log',array('type'=>2,'is_add'=>1,'mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']),'fee');
	$data['credit2inallday']=pdo_getsum('core_credit_log',array('type'=>2,'is_add'=>1,'mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid'],'createtime >'=>$daytime),'fee');
	$data['credit2inlastday']=pdo_getsum('core_credit_log',array('type'=>2,'is_add'=>1,'mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid'],'createtime between'=>array($lastdaytime,$daytime)),'fee');
	$data['credit2outall']=pdo_getsum('core_credit_log',array('type'=>2,'is_add'=>0,'mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']),'fee');
	$data['credit3inall']=pdo_getsum('core_credit_log',array('type'=>3,'is_add'=>1,'mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']),'fee');
	$data['credit3inallday']=pdo_getsum('core_credit_log',array('type'=>3,'is_add'=>1,'mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid'],'createtime >'=>$daytime),'fee');
	$data['credit3inlastday']=pdo_getsum('core_credit_log',array('type'=>3,'is_add'=>1,'mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid'],'createtime between'=>array($lastdaytime,$daytime)),'fee');
	$data['credit3outall']=pdo_getsum('core_credit_log',array('type'=>3,'is_add'=>0,'mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']),'fee');
	$data['credit4inall']=pdo_getsum('core_member_cash',array('mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']),'money');
	$data['credit4inallday']=pdo_getsum('core_member_cash',array('mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid'],'createtime >'=>$daytime),'money');
	$data['credit4inlastday']=pdo_getsum('core_member_cash',array('mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid'],'createtime between'=>array($lastdaytime,$daytime)),'money');
	$data['credit4outall']=pdo_getsum('core_member_cash',array('mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']),'money');
	$return['data']=$data;
	$member=model('core/member')->detail($_SESSION['uid'],array('credit1','credit2','credit3','credit4','credit5','credit6','mobile','avatar','nickname'));
	$return['member']=$member;
	$return['list']=array();
	$return['params']=array('type2'=>$type?:3);
	set_html('title','收益明细');
	exi($return);
}
if($_RQ['op']=='list'){	
	$params=array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']);
	$type=intval($_RQ['type2'])?:intval($_RQ['type']);
	if($type){
		$params['type']=$type;
		$return['params']['type']=$type;
	}
	$credit_types=credit_types();
	$pindex = max(1, intval($_RQ['page']));
	$psize = 20;
	$total='';
	$list=pdo_getslice('core_credit_log',$params,array($pindex,$psize),$total,array('id','type','is_add','fee','remark','createtime'),'','id desc');
	if($list){
		foreach($list as &$item){
			$item['createtime']=date('Y/m/d H:i:s',$item['createtime']);
			$item['is_addtitle']=$item['is_add']?'获得':'消费';
			$item['typetitle']=$credit_types[$item['type']];
		}
	}
	$return['list']=$list;
	exi($return);
}
?>